home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 6 code / TCP / NewsWatcher / NW Source / Shared Code / Reusable Source / key.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-05  |  2.5 KB  |  104 lines  |  [TEXT/MMCC]

  1. /*----------------------------------------------------------------------------
  2.  
  3.     key.c
  4.  
  5.     This reusable module handles miscellaneous tasks involving the keyboard.
  6.     
  7.     Copyright © 1994-1995, Northwestern University.
  8.  
  9. ----------------------------------------------------------------------------*/
  10.  
  11. #include "def.h"
  12. #include "key.h"
  13.  
  14.  
  15.  
  16. /*----------------------------------------------------------------------------
  17.     IsKeypadKey 
  18.     
  19.     Check for numeric keypad key.
  20.             
  21.     Entry:    theChar = ASCII code of key.
  22.             theKey = keyboard code of key.
  23.             
  24.     Exit:    function result = true if numeric keypad key.
  25.             *theKeypadKey = which keypad key, if function result is true.
  26. ----------------------------------------------------------------------------*/
  27.  
  28. Boolean IsKeypadKey (unsigned char theChar, unsigned char theKey, 
  29.     TKeypadKey *theKeypadKey)
  30. {
  31.     if (theChar == 0x1B && theKey == 0x47) {
  32.         *theKeypadKey = kKeypadClearKey;
  33.         return true;
  34.     }
  35.     if (theChar == '=' && (theKey == 0x48 || theKey == 0x51)) {
  36.         *theKeypadKey = kKeypadEqualKey;
  37.         return true;
  38.     }
  39.     if (theChar == '/' && (theKey == 0x4d || theKey == 0x4b)) {
  40.         *theKeypadKey = kKeypadSlashKey;
  41.         return true;
  42.     }    
  43.     if (theChar == '*' && (theKey == 0x42 || theKey == 0x43)) {
  44.         *theKeypadKey = kKeypadStarKey;
  45.         return true;
  46.     }
  47.     if (theChar == '-' && theKey == 0x4e) {
  48.         *theKeypadKey = kKeypadMinusKey;
  49.         return true;
  50.     }
  51.     if (theChar == '+' && (theKey == 0x46 || theKey == 0x45)) {
  52.         *theKeypadKey = kKeypadPlusKey;
  53.         return true;
  54.     }
  55.     if (theChar == enterKey && theKey == 0x4c) {
  56.         *theKeypadKey = kKeypadEnterKey;
  57.         return true;
  58.     }
  59.     if ((theChar == '.' || theChar == ',') && theKey == 0x41) {
  60.         *theKeypadKey = kKeypadPeriodKey;
  61.         return true;
  62.     }
  63.     if (theChar == '0' && theKey == 0x52) {
  64.         *theKeypadKey = kKeypad0Key;
  65.         return true;
  66.     }
  67.     if (theChar == '1' && theKey == 0x53) {
  68.         *theKeypadKey = kKeypad1Key;
  69.         return true;
  70.     }
  71.     if (theChar == '2' && theKey == 0x54) {
  72.         *theKeypadKey = kKeypad2Key;
  73.         return true;
  74.     }
  75.     if (theChar == '3' && theKey == 0x55) {
  76.         *theKeypadKey = kKeypad3Key;
  77.         return true;
  78.     }
  79.     if (theChar == '4' && theKey == 0x56) {
  80.         *theKeypadKey = kKeypad4Key;
  81.         return true;
  82.     }
  83.     if (theChar == '5' && theKey == 0x57) {
  84.         *theKeypadKey = kKeypad5Key;
  85.         return true;
  86.     }
  87.     if (theChar == '6' && theKey == 0x58) {
  88.         *theKeypadKey = kKeypad6Key;
  89.         return true;
  90.     }
  91.     if (theChar == '7' && theKey == 0x59) {
  92.         *theKeypadKey = kKeypad7Key;
  93.         return true;
  94.     }
  95.     if (theChar == '8' && theKey == 0x5b) {
  96.         *theKeypadKey = kKeypad8Key;
  97.         return true;
  98.     }
  99.     if (theChar == '9' && theKey == 0x5c) {
  100.         *theKeypadKey = kKeypad9Key;
  101.         return true;
  102.     }
  103.     return false;
  104. }